<template>
    <section>
        <el-col :span="24" style="padding-left:16px;padding-top:10px;padding-bottom:10px;"> 
              <el-button round type="primary" 
               size="small" icon="el-icon-plus">创建公司</el-button> 
            
        </el-col>     
    </section>

</template>

<script>
import api from "@/service/api";
import http from "@/service/http";
import store from "@/store";
import { createNamespacedHelpers } from "vuex";
const { mapActions ,mapGetters} = createNamespacedHelpers("system/role");

export default {
  data() {
    return {
      dialogFormVisible: false,
      loading: false,
      addForm: {
        roleName: "",
        note: ""
      },
      rules: {
        roleName: [
          { required: true, message: "请输入角色名", trigger: "blur" }
        ]
      },
    };
  },
  methods: {
    //导入actions方法
    ...mapActions(["getRoles"]),
    submitForm(formName) { 
      this.$refs[formName].validate(valid => {
        if (valid) {
          var param = {
            roleName: this.addForm.roleName,
            note: this.addForm.note
          };
          this.addRole(param);
        } else {
          return false;
        }
      });
    },
    addRole(param) {
      this.loading = true;
      http.post(api.sysApi.addRole, param).then(data => {
        if(!data.success){
          return;
        }
        this.$message({
          showClose: true,
          message: "添加成功",
          type: "success"
        });
        //更新列表
        this.getRoles();
        this.dialogFormVisible = false;
        this.loading = false;
      });
    }
  }
};
</script>

<style> 

</style>

